1. Field of the Invention
The present invention generally relates to an apparatus and method for efficient and fast code coverage analysis. Generally, code coverage analysis is a technique that checks which program code blocks have been executed during testing.
2. Description of Related Art
As is known in the computer and software arts, when a software program is developed, it will contain errors. As a consequence, developers of the software program utilize many techniques in which to check the correctness of the program and to diagnose errors. One of the techniques that developers will often use is a benchmark test to check the code coverage of the program. The best benchmark tests check as many different code blocks and combinations as possible (i.e., code coverage).
The result of a code coverage analysis can be processed in many different ways. One is a single percentage number showing the amount of code covered in the test. For a single test run, the one percentage number can be used directly.
Another way is a map of where the covered code is located. For multiple test runs, the percentages cannot be combined by adding the results as there will be a large amount of duplicated coverage. In multiple test run cases, a map of the code blocks hit must be kept for the first run case and updates must be made to the map when new test results are combined. The percentage can then be computed after obtaining cumulated results in the map.
One of the methods to check if all the code in the program has been tested (i.e., code coverage) is to utilize the inclusion of a display message indicating when each block of code is entered, thereby enabling the developer to test which blocks of code have been entered and tested. The greatest problem with the inclusion of display messages in the first line of each block of code is the developer""s time to include a display statement at the beginning of each block of code, and the time to actually execute the modified program. These extra instructions slow down the execution a lot due to input/output (I/O) operations and plainly due to more instructions having to be executed. A further overhead factor is that each program must be recompiled or reassembled and linked with the additional display commands. Furthermore, another problem with this method is the additional paper resource that is required to trace where the execution of the program is currently situated.
Another method of code coverage analysis, similar to the displaying of a message at the beginning of each block in the software program, is to include instead a write to file a statement in the beginning of each code block. The output file shows each portion of the software program entered
Problems with this write to file method, again as stated above for the display technique, include the extended program execution time, the developer""s time to include a write to file statement at the beginning of each block of code, and the time required to recompile, reassemble, and execute a link program. Also, the amount of disk storage required for such write to file could be an enormous resource demand.
Heretofore, software developers have lacked an apparatus and method for accomplishing code coverage analysis in an efficient way.
Certain objects, advantages and novel features of the invention will be set forth in part in the description that follows and in part will become apparent to those skilled in the art upon examination of the following description or may be learned with the practice of the invention. The objects, features and advantages of the invention may be realized and obtained by means of the instrumentalities and combinations particularly recited in the appended claims.
To achieve the advantages and novel features, the present invention is generally directed to an apparatus and method for fast and efficient code coverage analysis. The present invention for fast code coverage analysis utilizes a technique that provides for capturing an event whenever a block of code is visited for the first time. This allows for generating an event only once during numerous executions of a code block. The generation of only one event will provide for execution time close to the speed of the original source code. The speed of the code coverage analysis execution is now provided in an efficient way.
The present invention further utilizes an apparatus and method where each time a branch is executed, a high level control looks up the branch target program counter in the code cache in order to see if there is a code block corresponding to the branch target program counter. If the program block is found within the code cache, then the high level control determines if that code block has already been executed and proceeds with further execution of the copied source code in code cache.
If the high level control does not find the code within the code cache, then the high level control determines that this is the first time that code block has been executed in the original source program and copies that code block from the original source program into the code cache and provides notification of the first execution of the block of code. This allows a developer to calculate the amount of lines executed in the test run of the program as compared to the total amount of code lines in the original source code.